<!DOCTYPE html>
<html>
<head>
<#include "/admin/common/common.ftl" parse=true encoding="utf-8">
<link href="${base}/scripts/ckeditor/skins/moono/editor.css" type="text/css" rel="stylesheet">
<style>
</style>
</head>

<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">

  <#include "/admin/common/header.ftl" parse=true encoding="utf-8">

  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
	    <!-- Content Header (Page header) -->
	    <section class="content-header">
	      <h1>系统设置</h1>
	      <ol class="breadcrumb">
					<li class="active">系统设置管理</li>
				</ol>
	    </section>
	
	    <!-- Main content -->
			<section class="content">
				<!-- Info boxes -->
				<div class="row">
					<div class="box box-primary">
						<div class="box-body">
							<form class="form-horizontal" role="form" id="myForm">
								<fieldset>
									<div class="form-group col-md-6">
										<label for="firstname" class="col-md-4 control-label">系统默认邮件主机</label>
										<div class="col-md-8">
											<input type="text" class="form-control" id="defaultMailHost" name="defaultMailHost" value="${entity.defaultMailHost!}">
										</div>
									</div>
									<div class="form-group col-md-6">
										<label for="firstname" class="col-md-4 control-label">系统默认邮件端口</label>
										<div class="col-md-8">
											<input type="text" class="form-control" id="defaultMailPort" name="defaultMailPort" value="${entity.defaultMailPort!}">
										</div>
									</div>
								</fieldset>
								<fieldset>
									<div class="form-group col-md-6">
										<label for="firstname" class="col-md-4 control-label">系统默认邮件用户名</label>
										<div class="col-md-8">
											<input type="text" class="form-control" id="defaultMailUsername" name="defaultMailUsername" value="${entity.defaultMailUsername!}">
										</div>
									</div>
									<div class="form-group col-md-6">
										<label for="firstname" class="col-md-4 control-label">系统默认邮件密码</label>
										<div class="col-md-8">
											<input type="password" class="form-control" id="defaultMailPassword" name="defaultMailPassword" value="${entity.defaultMailPassword!}">
										</div>
									</div>
								</fieldset>
								<div class="form-group col-md-6">
									<label for="firstname" class="col-md-4 control-label">是否开放注册</label>
									<div class="col-md-8 form-control-static">
										<input type="radio" name="defaultConfigIsOpenRegister" value="1"
										<#if (entity.defaultConfigIsOpenRegister??) && (entity.defaultConfigIsOpenRegister == '1')>checked="checked"</#if>><span>是</span>
										<input type="radio" name="defaultConfigIsOpenRegister" value="0"
										<#if (entity.defaultConfigIsOpenRegister??) && (entity.defaultConfigIsOpenRegister == '0')>checked="checked"</#if>><span>否</span>
									</div>
								</div>
								<div class="form-group col-md-6">
									<label for="firstname" class="col-md-4 control-label">是否开放登录</label>
									<div class="col-md-8 form-control-static">
										<input type="radio" name="defaultConfigIsOpenLogin" value="1"
										<#if (entity.defaultConfigIsOpenLogin??) && (entity.defaultConfigIsOpenLogin == '1')>checked="checked"</#if>><span>是</span>
										<input type="radio" name="defaultConfigIsOpenLogin" value="0"
										<#if (entity.defaultConfigIsOpenLogin??) && (entity.defaultConfigIsOpenLogin == '0')>checked="checked"</#if>><span>否</span>
									</div>
								</div>
								<div class="form-group">
									<div class="col-md-12 text-center">
										<button type="submit" class="btn btn-primary">保存</button>
										<button type="button" class="btn btn-default" onclick="history.go(-1);">返回</button>
									</div>
								</div>
							</form>
						</div>
						<!-- /.box-body -->
					</div>
					<!-- /.box -->
				</div>
				<!-- /.row -->
			</section>
	</div>
	
</div>

<!-- ./wrapper -->
	<#include "/admin/common/footer.ftl" parse=true encoding="utf-8">

</body>
	
<script src="${base}/scripts/common/imgphoto.js"></script>

<script type="text/javascript">
	$('#myForm').bootstrapValidator(
					{
						message : '该项不能为空',
						live : 'disabled',
						feedbackIcons : {
							valid : 'glyphicon glyphicon-ok',
							invalid : 'glyphicon glyphicon-remove',
							validating : 'glyphicon glyphicon-refresh'
						},
						submitHandler : function(validator, form,
								submitButton) {
							bootbox.setLocale("zh_CN");
							bootbox.confirm("确定要保存吗？", function (result) {  
								if(result) {  
									var url = "${base}/admin/system/setting/saveAction.json";
									var entity = {
										defaultMailHost : $("#defaultMailHost")
												.val(),
										defaultMailPort : $("#defaultMailPort")
												.val(),
										defaultMailUsername : $(
												"#defaultMailUsername").val(),
										defaultMailPassword : $(
												"#defaultMailPassword").val(),
										defaultConfigIsOpenRegister:$("input[name='defaultConfigIsOpenRegister']:checked").val(),
										defaultConfigIsOpenLogin:$("input[name='defaultConfigIsOpenLogin']:checked").val()
									};
									var onloadFunc = function(result) {
										if (result.isSuccess == true) {
											bootbox.alert('修改成功', function (result) {  
												window.location.reload();
								            });
										} else {
											bootbox.alert(result.message, function (result) {  
								            }); 
										}
									};
									httpRequestPostJson(url, entity, false, onloadFunc);
				                }
				            }); 
						},
						fields : {
							defaultMailHost : {
								message : '角色名称无效',
								validators : {
									notEmpty : {
										message : '主机不能为空'
									},
									stringLength : {
										min : 2,
										max : 25,
										message : '主机名的长度介于2-25字符之间'
									}
								}
							},
							defaultMailPort : {
								message : '角色名称无效',
								validators : {
									notEmpty : {
										message : '邮件端口不能为空'
									},
									stringLength : {
										min : 2,
										max : 25,
										message : '端口号的长度介于2-25字符之间'
									}
								}
							},
							defaultMailUsername : {
								message : '角色名称无效',
								validators : {
									notEmpty : {
										message : '邮件用户名不能为空'
									},
									stringLength : {
										min : 2,
										max : 25,
										message : '邮件用户名的长度介于2-25字符之间'
									}
								}
							},
							defaultMailPassword : {
								message : '角色名称无效',
								validators : {
									notEmpty : {
										message : '密码不能为空'
									},
									stringLength : {
										min : 2,
										max : 25,
										message : '密码的长度介于2-25字符之间'
									}
								}
							},
						}
					});
</script>
</html>
